package com.xiaocg;

import java.util.concurrent.*;

public class NettyDemo {
    public static void main(String[] args) throws Exception{
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10,
                50, 10, TimeUnit.SECONDS, new ArrayBlockingQueue<>(50));

        CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("supplyAsync");
            return "ddd";
        },threadPoolExecutor).whenComplete((v,e)->{
            System.out.println(v);
        }).exceptionally(e -> {
            System.out.println(e.getMessage());
            return null;
        });

        threadPoolExecutor.shutdown();
    }
}
